package io;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/*
    缓冲输出流的缓冲区问题
 */
public class BOSDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("demo.txt", true);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        String line = "我真的诙谐";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);
        bos.write(data);
        /*
            void flush()
            会将当前缓冲区已经缓存的数据一次性的写出
            bos.flush();//flush冲水
         */
        System.out.println("写出完毕！");
        bos.close();
    }
}
